package top.glkj.hms.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.List;

/**
 * @author : xgl
 * @version : 0.0.1
 * @date :2020/11/25 1:42
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "hms_room_type")
public class RoomType extends BaseEntity {
    /**
     * 类型名称
     */
    @Column(name="type_name")
    private String typeName;


    /**
     * 基本日租费用
     */
    @Column(name = "base_daily_rent")
    private double baseDailyRent;
    /**
     * 基本时租费用
     */
    @Column(name = "base_hourly_rate")
    private double baseHourlyRate;

    /**
     * 该类型房间下的的共有基础设施
     */
    @Fetch(FetchMode.SUBSELECT)
    @ManyToMany(targetEntity = HotelFacilities.class,cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "hms_room_type_hotel_facilities",
            //当前对象在中间表中的外键
            joinColumns = {@JoinColumn(name = "room_type_id", referencedColumnName = "id")},
            //对方对象在中间表中的外键
            inverseJoinColumns = {@JoinColumn(name = "hotel_facilities_id", referencedColumnName = "id")}
    )
    private List<HotelFacilities> hotelFacilitiesList;
}
